<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
	<title>角色管理</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- 样式文件的引入 -->
	<link href="/comm-work-flow-server/commons/css/style.css" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="/comm-work-flow-server/commons/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="/comm-work-flow-server/commons/themes/icon.css">
	<!-- jqueryUI JS文件的引入 -->
	<script type="text/javascript" src="/comm-work-flow-server/commons/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="/comm-work-flow-server/commons/js/jquery.easyui.min.js"></script>
	<!-- 开发使用的公用js方法 -->
	<script type="text/javascript" src="/comm-work-flow-server/commons/js/common.js"></script>
	<script type="text/javascript" src="/comm-work-flow-server/commons/js/easyui-lang-zh_CN.js"></script>
	<!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
	<script type="text/javascript">var ctx = '/comm-work-flow-server';var actionExt = "action";var i18n = new Object();</script>
	<script src="/comm-work-flow-server/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
	<!--[if lt IE 9]>
	<?import namespace="v" implementation="#default#VML" ?>
	<![endif]-->
</head>
  <body>
    <div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'north',border:false">
		<div class="queryContent" style="height: 32px;">
			<form name="searchForm" id="searchForm" method="post" action="" style="display: none; ">
				<table class="queryTable" >
					<tbody>
						<tr>
							<th width="80%" style="text-align: right;">所属系统 </th>
							<td width="10%">
							<input class="easyui-combobox" style="width:280px" name="businessName" data-options="valueField:'id',textField:'text',url:'get_data.php'">
								<input class="easyui-validatebox" type="button" value="创建业务系统" maxlength="50" style="width:120px"></input>
							</td>
						  <td align="right" width="10%"><a href="javascript:void(0);" class="easyui-linkbutton" id="search"  plain="true">查询</a>
							<a href="javascript:void(0);" class="easyui-linkbutton" id="resetSearch" plain="true">清空</a></td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
	
	<div data-options="region:'center',border:true">
			<table id="listTable" class="easyui-datagrid" 
				data-options="singleSelect:false,toolbar:'#tb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:false,
					pagination:true,remoteSort:true,multiSort:true,striped:true,onLoadSuccess:function(data){$('#'+paramObj.searchID).attr('disabled',false);},
					onLoadError:function(data){if($.trim(data.responseText) == 'unLogin'){
						var msn = ''||i18n[''];
						msn = msn||i18n[data.responseText];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='/';});
						}
					}},
					url:'/comm-work-flow-server/workflow/workflowinfo/list'"}>
				<thead>
					<tr>
						<th data-options="field:'id',checkbox:true"></th>
						<th data-options="field:'workFlowName',width:80,sortable:true,align:'left',halign:'center',formatter: function(value,row,index){
							return '<a href=javascript:void(0) onclick=openDrawFlowDialog(\''+row.id+'\')>'+value+'</a>';
						},title:'名称'"></th>
						<th data-options="field:'businessName',width:80,align:'center',title:'所属系统'"></th>
						<th data-options="field:'createName',width:40,align:'center',title:'创建人'"></th>
						<th data-options="field:'createTime',width:60,align:'center',title:'创建时间'"></th>
						<th data-options="field:'updateName',sortable:true,width:40,align:'center',title:'更新人'"></th>
						<th data-options="field:'updateTime',width:60,align:'center',title:'更新时间'"></th>
						<th data-options="field:'aa',width:60,align:'center',formatter: function(value,row,index){
							return '<a href=javascript:void(0) onclick=openDrawFlowDialog(\''+row.id+'\')>绑定人员</a>';
						},title:'操作'"></th>
					</tr>
				</thead>
			</table>
			<div id="tb" style="display: none;">
				<div>
					<a href="javascript:void(0);" onclick="openDrawFlowDialog();" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
					<a href="javascript:void(0);" onclick="updateFlowDate();" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
					<a href="javascript:void(0);" onclick="delFlow();" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
				</div>
			</div>
	</div>
	</div>
	<div id='firstLevelDialog'/>
  </body>
  <script type="text/javascript">
		//初始化表格对应的js对象
		var paramObj;
		$(function() {
			//初始化表格对象数据
			paramObj = new initParams(
					{
						paramObjName : 'paramObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
						tableId:'listTable',
						searchID:'search',
						resetSearchID:'resetSearch',
						searchFormID:'searchForm',
						deleteUrl:'/comm-work-flow-server/workflow/workflowinfo/remove'
					});
			//初始化查询
			init(paramObj);
		});
		// 得到待更新的记录
		function updateFlowDate(){
			var records = $('#'+paramObj.tableId).datagrid('getSelections');
			if(records.length != 1){
				$.messager.alert('提示',"请选择一条记录！",'info');
			}else{
				var record = records[0];
				openDrawFlowDialog(record.id);
			}
		}
		// 添加和更新数据记录
		function openDrawFlowDialog(workFlowId){
			if(workFlowId == undefined){
				workFlowId='';
			}
			top.$('#firstLevelDialog').dialog({    
			    title: '定制流程',  
			    iconCls:'icon-view',
			    width: 820,    
			    height: 488,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    modal: true,
			    href:null,
			    content:"<iframe id='flowSrc' frameborder='0' src='/comm-work-flow-server/workflow/workflowinfo/draw-work-flow.html?workFlowId="+workFlowId+"' width='100%' height='100%' scrolling='no' ></iframe>",
			    buttons : []
			}).dialog('open');
		}
		function saveSuccess(){
			queryData(paramObj);
		}
		
		function delFlow(){
			var records = $('#'+paramObj.tableId).datagrid('getSelections');
			if(records.length < 1){
				top.$.messager.alert('提示',"请选择记录！",'info');
			}else{
				var deleteIds = '';
				for(var i=0;i<records.length-1;i++){
					deleteIds += records[i].id+",";
				}
				deleteIds += records[records.length-1].id;
				$.messager.confirm('提示',"确定删除这条记录吗？",function(result){
					if(result){
						var msn = ''||i18n[''];
						$.ajax({
							type: "get",
							url:  paramObj.deleteUrl,
							data:'deleteIds='+deleteIds,
							success: function(data){
								var msn = ''||i18n[''];
								msn = msn||i18n[data];	
								if(msn == undefined){
									$.messager.alert('提示',i18n.serverError,'info');
								}else if(msn)	{	
									// TODO 使用动态提醒
									//animateShowMsg('ok', msn);
									//$('#'+paramObj.tableId).datagrid('reload');
									//$('#showDialog').dialog('close');
									$.messager.alert('提示',msn,'info',function(){$('#'+paramObj.tableId).datagrid('reload');});
								}
								/**if(!data.success){
									if(data.reason=='isUse'){
										top.$.messager.alert('提示',"已经被使用的流程不能删除！",'info');
									}else{
										top.$.messager.alert('提示',"系统异常，请重试！",'info');
									}
								}else{
									$('#'+paramObj.tableId).datagrid('unselectAll');
									$('#'+paramObj.tableId).datagrid('reload');
								}*/
							}
						});
					}
				});
			}
		}
	</script>
</html>
